package com.sg.service.biz.framework.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.common.util.RedisUtil;
import com.sg.dto.base.framework.req.*;
import com.sg.dto.biz.framework.req.*;
import com.sg.dto.biz.framework.res.*;
import com.sg.dto.integration.component.QueryClassMatchResultToAnswerDetailComReqDto;
import com.sg.dto.integration.component.QueryClassMatchResultToAnswerDetailComRespDto;
import com.wicket.okrcomponent.integration.ConfSchemeService;
import com.wicket.okrframework.common.annotations.BanAuto;
import com.sg.common.exception.Assert;
import com.wicket.okrframework.common.exception.BizException;
import com.wicket.okrframework.dal.po.mbg.*;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class CommonServiceImpl
        implements com.wicket.okrframework.biz.service.CommonService {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    private MSpaceService mSpaceService;
    @Resource
    private MSceneService mSceneService;
    @Resource
    private MUnionAppService mUnionAppService;
    @Resource
    private MOrganizationService mOrganizationService;
    @Resource
    private MMetadataObjectPropertyService mMetadataObjectPropertyService;
    @Resource
    private MMetadataCodeService mMetadataCodeService;
    @Resource
    private DataSource dataSource;
    @Resource
    private NbCommon nbCommon;
    @Resource
    private ConfSchemeService confSchemeService;

    /**
     * 空间信息存储缓存[1552]
     * gen by moon at 12/2/2022, 5:00:09 PM
     */
    @Trace(operationName = "空间信息存储缓存")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public PutSpaceInfoToRedisRespDto putSpaceInfoToRedis(PutSpaceInfoToRedisReqDto reqDto) {


        Space space_1 = null;
        Scene scene_1 = null;
        UnionApp unionApp_1 = null;
        UnionApp unionApp_3 = null;
        List<Organization> listOrganization_1 = new ArrayList<>();
        QueryClassMatchResultToAnswerDetailComRespDto queryClassMatchResultToAnswerDetailComRespDto_1 = null;
        QueryClassMatchResultToAnswerDetailComRespDto queryClassMatchResultToAnswerDetailComRespDto_3 = null;
//步骤0: 1-2-04查询空间详情 - querySpaceDetail
        Space space = null;
        QuerySpaceDetailReq querySpaceDetailReq = new QuerySpaceDetailReq();
        querySpaceDetailReq.setIsInvalid("FALSE");//sourceId:44382_1
        if (reqDto != null) {
            querySpaceDetailReq.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:44378_1
        }

        /*1-2-04查询空间详情[161]   */
        Assert.isNull(querySpaceDetailReq.getSpaceId(), "空间信息存储缓存-1-2-04查询空间详情-空间ID不能为空", false);
        space = mSpaceService.querySpaceDetail(querySpaceDetailReq);


        space_1 = space;

//步骤1: 1-2-07查询场景详情 - querySceneDetail
        Scene scene = null;
        if (space != null) {
            QuerySceneDetailReq querySceneDetailReq = new QuerySceneDetailReq();
            querySceneDetailReq.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:44410_1
            if (space != null) {
                querySceneDetailReq.setSceneId(space.getSubjectionSceneId());//SimpleFieldAssign//sourceId:44409_1
            }

            /*1-2-07查询场景详情[169]   */

            scene = mSceneService.querySceneDetail(querySceneDetailReq);


            scene_1 = scene;
        }

//步骤2: 1-2-06查询联盟应用详情 - queryAppDetail
        UnionApp unionApp = null;
        if (space != null) {
            QueryAppDetailReq queryAppDetailReq = new QueryAppDetailReq();
            if (space != null) {
                queryAppDetailReq.setAppId(space.getSubjectionAppId());//SimpleFieldAssign//sourceId:44415_1
            }

            /*1-2-06查询联盟应用详情[168]   */

            unionApp = mUnionAppService.queryAppDetail(queryAppDetailReq);


            unionApp_1 = unionApp;
        }

//步骤3: 1-2-06查询联盟应用详情 - queryAppDetail
        UnionApp unionApp_2 = null;
        QueryAppDetailReq queryAppDetailReq_1 = new QueryAppDetailReq();
        if (reqDto != null) {
            queryAppDetailReq_1.setUniqueSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:44485_1
        }

        /*1-2-06查询联盟应用详情[168]   */

        unionApp_2 = mUnionAppService.queryAppDetail(queryAppDetailReq_1);


        unionApp_3 = unionApp_2;

//步骤4: 1-3-12查询组织列表 - queryOrgList
        List<Organization> listOrganization = new ArrayList<>();
        QueryOrgListReq queryOrgListReq = new QueryOrgListReq();
        queryOrgListReq.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:44520_1
        queryOrgListReq.setManageLockStatus("UNLOCK");//sourceId:44521_1
        if (reqDto != null) {
            queryOrgListReq.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:44522_1
        }

        /*1-3-12查询组织列表[200]   */
        Assert.isNull(queryOrgListReq.getSubjectLifeCycle(), "空间信息存储缓存-1-3-12查询组织列表-主体生命周期不能为空", false);
        Assert.isNull(queryOrgListReq.getManageLockStatus(), "空间信息存储缓存-1-3-12查询组织列表-管理锁定状态不能为空", false);
        Assert.isNull(queryOrgListReq.getSpaceId(), "空间信息存储缓存-1-3-12查询组织列表-创建于空间ID不能为空", false);
        listOrganization = mOrganizationService.queryOrgList(queryOrgListReq);


        listOrganization_1 = listOrganization;

//步骤5: D2-3查询分组匹配结果转答案(公共)(跨服务） - queryClassMatchResultToAnswerDetailCom
        QueryClassMatchResultToAnswerDetailComRespDto queryClassMatchResultToAnswerDetailComRespDto = null;
        QueryClassMatchResultToAnswerDetailComReqDto queryClassMatchResultToAnswerDetailComReqDto = new QueryClassMatchResultToAnswerDetailComReqDto();
        queryClassMatchResultToAnswerDetailComReqDto.setResultAspObjId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID//sourceId:105561_1
        queryClassMatchResultToAnswerDetailComReqDto.setResultAspObjType("TENANT_SPACE");//sourceId:105562_1
        queryClassMatchResultToAnswerDetailComReqDto.setConfItemClassCode("TRIPLICITIES_SERVICE_CLASS");//CUSTOM_CONVENTION//sourceId:105412_1
        queryClassMatchResultToAnswerDetailComReqDto.setIsInitialScheme("TRUE");//sourceId:308520_1
        queryClassMatchResultToAnswerDetailComReqDto.setIsPlatData("TRUE");//sourceId:308521_1

        /*D2-3查询分组匹配结果转答案(第三方服务配置分组)[3088]   */
        Assert.isNull(queryClassMatchResultToAnswerDetailComReqDto.getResultAspObjId(), "空间信息存储缓存-D2-3查询分组匹配结果转答案(第三方服务配置分组)-答案归属对象ID不能为空", false);
        Assert.isNull(queryClassMatchResultToAnswerDetailComReqDto.getResultAspObjType(), "空间信息存储缓存-D2-3查询分组匹配结果转答案(第三方服务配置分组)-答案归属对象类型不能为空", false);
        Assert.isNull(queryClassMatchResultToAnswerDetailComReqDto.getConfItemClassCode(), "空间信息存储缓存-D2-3查询分组匹配结果转答案(第三方服务配置分组)-分组标识不能为空", false);
        Assert.isNull(queryClassMatchResultToAnswerDetailComReqDto.getIsInitialScheme(), "空间信息存储缓存-D2-3查询分组匹配结果转答案(第三方服务配置分组)-是否初始方案答案不能为空", false);
        Assert.isNull(queryClassMatchResultToAnswerDetailComReqDto.getIsPlatData(), "空间信息存储缓存-D2-3查询分组匹配结果转答案(第三方服务配置分组)-是否标准答案不能为空", false);
        queryClassMatchResultToAnswerDetailComRespDto = confSchemeService.queryClassMatchResultToAnswerDetailCom(queryClassMatchResultToAnswerDetailComReqDto).getData();


        queryClassMatchResultToAnswerDetailComRespDto_1 = queryClassMatchResultToAnswerDetailComRespDto;

//步骤6: D2-3查询分组匹配结果转答案(公共)(跨服务） - queryClassMatchResultToAnswerDetailCom
        QueryClassMatchResultToAnswerDetailComRespDto queryClassMatchResultToAnswerDetailComRespDto_2 = null;
        QueryClassMatchResultToAnswerDetailComReqDto queryClassMatchResultToAnswerDetailComReqDto_1 = new QueryClassMatchResultToAnswerDetailComReqDto();
        queryClassMatchResultToAnswerDetailComReqDto_1.setResultAspObjId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID//sourceId:105763_1
        queryClassMatchResultToAnswerDetailComReqDto_1.setResultAspObjType("TENANT_SPACE");//sourceId:105764_1
        queryClassMatchResultToAnswerDetailComReqDto_1.setConfItemClassCode("ORG_SET_CLASS");//CUSTOM_CONVENTION//sourceId:105722_1
        queryClassMatchResultToAnswerDetailComReqDto_1.setIsInitialScheme("TRUE");//sourceId:308522_1
        queryClassMatchResultToAnswerDetailComReqDto_1.setIsPlatData("FALSE");//sourceId:308523_1

        /*D2-3查询分组匹配结果转答案(组织架构设置分组)[3088]   */
        Assert.isNull(queryClassMatchResultToAnswerDetailComReqDto_1.getResultAspObjId(), "空间信息存储缓存-D2-3查询分组匹配结果转答案(组织架构设置分组)-答案归属对象ID不能为空", false);
        Assert.isNull(queryClassMatchResultToAnswerDetailComReqDto_1.getResultAspObjType(), "空间信息存储缓存-D2-3查询分组匹配结果转答案(组织架构设置分组)-答案归属对象类型不能为空", false);
        Assert.isNull(queryClassMatchResultToAnswerDetailComReqDto_1.getConfItemClassCode(), "空间信息存储缓存-D2-3查询分组匹配结果转答案(组织架构设置分组)-分组标识不能为空", false);
        Assert.isNull(queryClassMatchResultToAnswerDetailComReqDto_1.getIsInitialScheme(), "空间信息存储缓存-D2-3查询分组匹配结果转答案(组织架构设置分组)-是否初始方案答案不能为空", false);
        Assert.isNull(queryClassMatchResultToAnswerDetailComReqDto_1.getIsPlatData(), "空间信息存储缓存-D2-3查询分组匹配结果转答案(组织架构设置分组)-是否标准答案不能为空", false);
        queryClassMatchResultToAnswerDetailComRespDto_2 = confSchemeService.queryClassMatchResultToAnswerDetailCom(queryClassMatchResultToAnswerDetailComReqDto_1).getData();


        queryClassMatchResultToAnswerDetailComRespDto_3 = queryClassMatchResultToAnswerDetailComRespDto_2;

//步骤7: M-空间信息存储Redis（特殊方法） - setSpaceInfoToRedis
        //ModelCode: putSpaceInfoToRedis
        SetSpaceInfoToRedisRespDto putSpaceInfoToRedisRes = null;
        if (space != null) {
            SetSpaceInfoToRedisReqDto putSpaceInfoToRedisReq = new SetSpaceInfoToRedisReqDto();
            if (space != null) {
                putSpaceInfoToRedisReq.setSpaceId(space.getSpaceId());//SimpleFieldAssign//sourceId:47253_1
                putSpaceInfoToRedisReq.setSceneId(space.getSubjectionSceneId());//SimpleFieldAssign//sourceId:47254_1
                putSpaceInfoToRedisReq.setAppId(space.getSubjectionAppId());//SimpleFieldAssign//sourceId:47255_1
                putSpaceInfoToRedisReq.setSpaceCode(space.getSpaceCode());//SimpleFieldAssign//sourceId:47256_1
                putSpaceInfoToRedisReq.setSpaceName(space.getSpaceName());//SimpleFieldAssign//sourceId:47257_1
            }
            if (scene != null) {
                putSpaceInfoToRedisReq.setSenceCode(scene.getSenceCode());//SimpleFieldAssign//sourceId:47258_1
                putSpaceInfoToRedisReq.setSceneName(scene.getSceneName());//SimpleFieldAssign//sourceId:47259_1
            }
            if (unionApp != null) {
                putSpaceInfoToRedisReq.setAppCode(unionApp.getAppCode());//SimpleFieldAssign//sourceId:47260_1
                putSpaceInfoToRedisReq.setAppName(unionApp.getAppName());//SimpleFieldAssign//sourceId:47261_1
            }
            if (unionApp_2 != null) {
                putSpaceInfoToRedisReq.setAppIntroduce(unionApp_2.getAppIntroduce());//SimpleFieldAssign//sourceId:47262_1
                putSpaceInfoToRedisReq.setAppUpdateIntroduct(unionApp_2.getAppUpdateIntroduct());//SimpleFieldAssign//sourceId:47263_1
                putSpaceInfoToRedisReq.setWebsite(unionApp_2.getWebsite());//SimpleFieldAssign//sourceId:47264_1
                putSpaceInfoToRedisReq.setAppLogo(unionApp_2.getAppLogo());//SimpleFieldAssign//sourceId:47265_1
                putSpaceInfoToRedisReq.setAboutLogo(unionApp_2.getAboutLogo());//SimpleFieldAssign//sourceId:47266_1
                putSpaceInfoToRedisReq.setAppBanner(unionApp_2.getAppBanner());//SimpleFieldAssign//sourceId:47267_1
                putSpaceInfoToRedisReq.setServicePhone(unionApp_2.getServicePhone());//SimpleFieldAssign//sourceId:47268_1
                putSpaceInfoToRedisReq.setServiceTime(unionApp_2.getServiceTime());//SimpleFieldAssign//sourceId:47269_1
                putSpaceInfoToRedisReq.setCopyright(unionApp_2.getCopyright());//SimpleFieldAssign//sourceId:47270_1
                putSpaceInfoToRedisReq.setAppVersion(unionApp_2.getAppVersion());//SimpleFieldAssign//sourceId:47271_1
            }
            if (queryClassMatchResultToAnswerDetailComRespDto != null) {
                putSpaceInfoToRedisReq.setIsEnableSms(queryClassMatchResultToAnswerDetailComRespDto.getIsOpenSmsService());//SimpleFieldAssign//sourceId:63053_1
                putSpaceInfoToRedisReq.setIsUsePlatfomSms(queryClassMatchResultToAnswerDetailComRespDto.getIsUsePlatformSmsService());//SimpleFieldAssign//sourceId:63054_1
                putSpaceInfoToRedisReq.setAccessKeyId(queryClassMatchResultToAnswerDetailComRespDto.getAccessKeyId());//SimpleFieldAssign//sourceId:63055_1
                putSpaceInfoToRedisReq.setAccessKeySecret(queryClassMatchResultToAnswerDetailComRespDto.getAccessKeySecret());//SimpleFieldAssign//sourceId:63056_1
            }
            if (queryClassMatchResultToAnswerDetailComRespDto_2 != null) {
                putSpaceInfoToRedisReq.setIsOpenMultiOrg(queryClassMatchResultToAnswerDetailComRespDto_2.getOpenManyOrg());//SimpleFieldAssign//sourceId:63057_1
                putSpaceInfoToRedisReq.setOrgStructureModel(queryClassMatchResultToAnswerDetailComRespDto_2.getOrgStructureModel());//SimpleFieldAssign//sourceId:105781_1
                putSpaceInfoToRedisReq.setIsIntergration(queryClassMatchResultToAnswerDetailComRespDto_2.getIsIntergration());//SimpleFieldAssign//sourceId:105782_1
                putSpaceInfoToRedisReq.setIsAllowImport(queryClassMatchResultToAnswerDetailComRespDto_2.getIsAllowImport());//SimpleFieldAssign//sourceId:105783_1
                putSpaceInfoToRedisReq.setIsOpenApprovalProcess(queryClassMatchResultToAnswerDetailComRespDto_2.getIsOpenApprovalProcess());//SimpleFieldAssign//sourceId:105784_1
            }
            if (listOrganization != null && !CollectionUtil.isEmpty(listOrganization) && listOrganization != null && !CollectionUtil.isEmpty(listOrganization)) {
                putSpaceInfoToRedisReq.setOrgList(listOrganization.stream().map(item -> BeanUtil.toBean(item, OrgDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:47276_1
            }

            /*M-空间信息存储Redis（特殊方法）[1539]  用于用户前端登录成功后，将登录的空间信息缓存到REDIS中 */
            Assert.isNull(putSpaceInfoToRedisReq.getOrgStructureModel(), "空间信息存储缓存-M-空间信息存储Redis（特殊方法）-空间组织架构模式不能为空", false);
            Assert.isNull(putSpaceInfoToRedisReq.getIsIntergration(), "空间信息存储缓存-M-空间信息存储Redis（特殊方法）-是否开启系统对接不能为空", false);
            Assert.isNull(putSpaceInfoToRedisReq.getIsAllowImport(), "空间信息存储缓存-M-空间信息存储Redis（特殊方法）-是否允许导入不能为空", false);
            Assert.isNull(putSpaceInfoToRedisReq.getIsOpenApprovalProcess(), "空间信息存储缓存-M-空间信息存储Redis（特殊方法）-是否启用流程审批不能为空", false);
            putSpaceInfoToRedisRes = nbCommon.setSpaceInfoToRedis(putSpaceInfoToRedisReq);


        }

        PutSpaceInfoToRedisRespDto retData = new PutSpaceInfoToRedisRespDto();
        retData.setOrgList(listOrganization_1.stream().map(item -> BeanUtil.toBean(item, OrgDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:49287_1
        if (space_1 != null) {
            retData.setSpaceId(space_1.getSpaceId());//SimpleFieldAssign//sourceId:49261_1
            retData.setSpaceCode(space_1.getSpaceCode());//SimpleFieldAssign//sourceId:49266_1
            retData.setSpaceName(space_1.getSpaceName());//SimpleFieldAssign//sourceId:49269_1
            retData.setSubjectionSceneId(space_1.getSubjectionSceneId());//SimpleFieldAssign//sourceId:49279_1
            retData.setSubjectionAppId(space_1.getSubjectionAppId());//SimpleFieldAssign//sourceId:49281_1
        }
        if (scene_1 != null) {
            retData.setSceneId(scene_1.getSceneId());//SimpleFieldAssign//sourceId:49262_1
            retData.setSenceCode(scene_1.getSenceCode());//SimpleFieldAssign//sourceId:49264_1
            retData.setSceneName(scene_1.getSceneName());//SimpleFieldAssign//sourceId:49267_1
        }
        if (unionApp_1 != null) {
            retData.setAppId(unionApp_1.getAppId());//SimpleFieldAssign//sourceId:49263_1
            retData.setAppCode(unionApp_1.getAppCode());//SimpleFieldAssign//sourceId:49265_1
            retData.setAppName(unionApp_1.getAppName());//SimpleFieldAssign//sourceId:49268_1
        }
        if (unionApp_3 != null) {
            retData.setAppIntroduce(unionApp_3.getAppIntroduce());//SimpleFieldAssign//sourceId:49270_1
            retData.setAppUpdateIntroduct(unionApp_3.getAppUpdateIntroduct());//SimpleFieldAssign//sourceId:49271_1
            retData.setWebsite(unionApp_3.getWebsite());//SimpleFieldAssign//sourceId:49272_1
            retData.setAppLogo(unionApp_3.getAppLogo());//SimpleFieldAssign//sourceId:49273_1
            retData.setAboutLogo(unionApp_3.getAboutLogo());//SimpleFieldAssign//sourceId:49274_1
            retData.setAppBanner(unionApp_3.getAppBanner());//SimpleFieldAssign//sourceId:49275_1
            retData.setServicePhone(unionApp_3.getServicePhone());//SimpleFieldAssign//sourceId:49276_1
            retData.setServiceTime(unionApp_3.getServiceTime());//SimpleFieldAssign//sourceId:49277_1
            retData.setCopyright(unionApp_3.getCopyright());//SimpleFieldAssign//sourceId:49278_1
            retData.setAppVersion(unionApp_3.getAppVersion());//SimpleFieldAssign//sourceId:49280_1
        }
        if (queryClassMatchResultToAnswerDetailComRespDto_3 != null) {
            retData.setOpenManyOrg(queryClassMatchResultToAnswerDetailComRespDto_3.getOpenManyOrg());//SimpleFieldAssign//sourceId:105785_1
        }
        if (queryClassMatchResultToAnswerDetailComRespDto_1 != null) {
            retData.setIsOpenSmsService(queryClassMatchResultToAnswerDetailComRespDto_1.getIsOpenSmsService());//SimpleFieldAssign//sourceId:105786_1
            retData.setIsUsePlatformSmsService(queryClassMatchResultToAnswerDetailComRespDto_1.getIsUsePlatformSmsService());//SimpleFieldAssign//sourceId:105787_1
            retData.setAccessKeyId(queryClassMatchResultToAnswerDetailComRespDto_1.getAccessKeyId());//SimpleFieldAssign//sourceId:105856_1
            retData.setAccessKeySecret(queryClassMatchResultToAnswerDetailComRespDto_1.getAccessKeySecret());//SimpleFieldAssign//sourceId:105857_1
        }


        return retData;
    }

    /**
     * D1查询空间框架信息前端缓存[1405]
     * gen by moon at 10/2/2022, 12:03:50 AM
     */
    @Trace(operationName = "D1查询空间框架信息前端缓存")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryFrontPublicInfoListRespDto queryFrontPublicInfoList(QueryFrontPublicInfoListReqDto reqDto) {


        List<MetadataObjectProperty> listMetadataObjectProperty_1 = new ArrayList<>();
        List<MetadataCode> listMetadataCode_1 = new ArrayList<>();
//步骤0: 1-1-04查询对象属性列表 - queryObjAttributeList
        List<MetadataObjectProperty> listMetadataObjectProperty = new ArrayList<>();
        QueryObjAttributeListReq queryObjAttributeListReq = new QueryObjAttributeListReq();
        queryObjAttributeListReq.setIsEnumeration("TRUE");//sourceId:32439_1
        queryObjAttributeListReq.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:32440_1
        queryObjAttributeListReq.setIsRecordVersion("TRUE");//sourceId:230108_1

        /*1-1-04查询对象属性列表[220]   */
        Assert.isNull(queryObjAttributeListReq.getIsEnumeration(), "D1查询空间框架信息前端缓存-1-1-04查询对象属性列表-是否枚举字段不能为空", false);
        Assert.isNull(queryObjAttributeListReq.getSubjectLifeCycle(), "D1查询空间框架信息前端缓存-1-1-04查询对象属性列表-主体生命周期不能为空", false);
        Assert.isNull(queryObjAttributeListReq.getIsRecordVersion(), "D1查询空间框架信息前端缓存-1-1-04查询对象属性列表-字段更新是否前端显示不能为空", false);
        listMetadataObjectProperty = mMetadataObjectPropertyService.queryObjAttributeList(queryObjAttributeListReq);


        listMetadataObjectProperty_1 = listMetadataObjectProperty;

//步骤1: 1-1-13查询编码列表 - queryCodeList
        List<MetadataCode> listMetadataCode = new ArrayList<>();
        QueryCodeListReq queryCodeListReq = new QueryCodeListReq();
        queryCodeListReq.setIsPushCache("TRUE");//sourceId:193639_1
        queryCodeListReq.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:32441_1

        /*1-1-13查询编码列表[649]   */
        Assert.isNull(queryCodeListReq.getIsPushCache(), "D1查询空间框架信息前端缓存-1-1-13查询编码列表-是否推送前端缓存不能为空", false);
        Assert.isNull(queryCodeListReq.getSubjectLifeCycle(), "D1查询空间框架信息前端缓存-1-1-13查询编码列表-主体生命周期不能为空", false);
        listMetadataCode = mMetadataCodeService.queryCodeList(queryCodeListReq);


        listMetadataCode_1 = listMetadataCode;

        QueryFrontPublicInfoListRespDto retData = new QueryFrontPublicInfoListRespDto();
        retData.setTypeEncodingList(listMetadataCode_1.stream().map(item -> BeanUtil.toBean(item, TypeEncodingDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:32443_1
        retData.setBaseMetadataObjectPropertyList(listMetadataObjectProperty_1.stream().map(item -> BeanUtil.toBean(item, BaseMetadataObjectPropertyDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:32444_1


        return retData;
    }

    /**
     * D1-发布单条数据[2329]
     * gen by moon at 8/10/2022, 3:21:22 AM
     */
    @Trace(operationName = "D1-发布单条数据")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ReleaseSingleDataRespDto releaseSingleData(ReleaseSingleDataReqDto reqDto) {


        //步骤0: M-发布单条数据（特殊方法） - releaseSingleDataCom
        //ModelCode: releaseSingleDataCom
        try {
            CommonFunctionHelper.nbDbWorker(dataSource.getConnection(), reqDto, "releaseSingleDataCom", null);
        } catch (Exception e) {
            throw new BizException("-1", e, false);
        }

        ReleaseSingleDataRespDto retData = new ReleaseSingleDataRespDto();


        return retData;
    }

    /**
     * D1-撤销存档批次下单条数据[2328]
     * gen by moon at 8/10/2022, 3:21:18 AM
     */
    @Trace(operationName = "D1-撤销存档批次下单条数据")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public UndoArchiveBatchSingleDataRespDto undoArchiveBatchSingleData(UndoArchiveBatchSingleDataReqDto reqDto) {


        //步骤0: M-撤销存档批次下单条数据（特殊方法） - undoArchiveBatchSingleDataCom
        //ModelCode: undoArchiveBatchSingleDataCom
        try {
            CommonFunctionHelper.nbDbWorker(dataSource.getConnection(), reqDto, "undoArchiveBatchSingleDataCom", null);
        } catch (Exception e) {
            throw new BizException("-1", e, false);
        }

        UndoArchiveBatchSingleDataRespDto retData = new UndoArchiveBatchSingleDataRespDto();


        return retData;
    }

    /**
     * D1-存档批次下单条数据[2327]
     * gen by moon at 8/10/2022, 3:21:13 AM
     */
    @Trace(operationName = "D1-存档批次下单条数据")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ArchiveBatchSingleDataRespDto archiveBatchSingleData(ArchiveBatchSingleDataReqDto reqDto) {


        //步骤0: M-存档批次下单条数据（特殊方法） - archiveBatchSingleDataCom
        //ModelCode: archiveBatchSingleDataCom
        try {
            CommonFunctionHelper.nbDbWorker(dataSource.getConnection(), reqDto, "archiveBatchSingleDataCom", null);
        } catch (Exception e) {
            throw new BizException("-1", e, false);
        }

        ArchiveBatchSingleDataRespDto retData = new ArchiveBatchSingleDataRespDto();


        return retData;
    }

    /**
     * D1-修改排序[1530]
     * gen by moon at 8/10/2022, 3:17:08 AM
     */
    @Trace(operationName = "D1-修改排序")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public UpdateSortNumRespDto updateSortNum(UpdateSortNumReqDto reqDto) {


        //步骤0: M-修改排序（特殊方法） - updateSortNum
        //ModelCode: updateSortNumCom
        try {
            CommonFunctionHelper.nbDbWorker(dataSource.getConnection(), reqDto, "updateSortNumCom", null);
        } catch (Exception e) {
            throw new BizException("-1", e, false);
        }

        UpdateSortNumRespDto retData = new UpdateSortNumRespDto();


        return retData;
    }

    /**
     * D1-删除单条数据[2330]
     * gen by moon at 10/2/2022, 2:38:00 AM
     */
    @Trace(operationName = "D1-删除单条数据")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public DeleteSingleDataRespDto deleteSingleData(DeleteSingleDataReqDto reqDto) {


        //步骤0: M-删除单条数据（特殊方法） - deleteSingleDataCom
        //ModelCode: deleteSingleDataCom
        DeleteSingleDataComRespDto deleteSingleDataComRes = null;
        DeleteSingleDataComReqDto deleteSingleDataComReq = new DeleteSingleDataComReqDto();
        if (reqDto != null) {
            deleteSingleDataComReq.setObjectCode(reqDto.getObjectCode());//SimpleFieldAssign//sourceId:68259_1
            deleteSingleDataComReq.setPropertyCode(reqDto.getPropertyCode());//SimpleFieldAssign//sourceId:68260_1
            deleteSingleDataComReq.setUniqueId(reqDto.getUniqueId());//SimpleFieldAssign//sourceId:68261_1
        }

        /*M-删除单条数据（特殊方法）[2325]  用于公共接口，入参表名、表主键名、表主键ID。用于删除入参表中的入参数据记录 */

        deleteSingleDataComRes = nbCommon.deleteSingleDataCom(deleteSingleDataComReq);


        DeleteSingleDataRespDto retData = new DeleteSingleDataRespDto();


        return retData;
    }

    /**
     * D1-存档单条数据[2326]
     * gen by moon at 10/2/2022, 2:27:12 AM
     */
    @Trace(operationName = "D1-存档单条数据")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ArchiveSingleDataRespDto archiveSingleData(ArchiveSingleDataReqDto reqDto) {


        //步骤0: M-存档单条数据（特殊方法） - archiveSingleDataCom
        //ModelCode: archiveSingleDataCom
        ArchiveSingleDataComRespDto archiveSingleDataComRes = null;
        ArchiveSingleDataComReqDto archiveSingleDataComReq = new ArchiveSingleDataComReqDto();
        if (reqDto != null) {
            archiveSingleDataComReq.setObjectCode(reqDto.getObjectCode());//SimpleFieldAssign//sourceId:68235_1
            archiveSingleDataComReq.setPropertyCode(reqDto.getPropertyCode());//SimpleFieldAssign//sourceId:68236_1
            archiveSingleDataComReq.setUniqueId(reqDto.getUniqueId());//SimpleFieldAssign//sourceId:68237_1
        }

        /*M-存档单条数据（特殊方法）[2321]  用于公共接口，入参表名、表主键名、表主键ID。用于存档入参表中的入参数据记录 */

        archiveSingleDataComRes = nbCommon.archiveSingleDataCom(archiveSingleDataComReq);


        ArchiveSingleDataRespDto retData = new ArchiveSingleDataRespDto();


        return retData;
    }

    /**
     * D-批量改排序[1808]
     * gen by moon at 10/2/2022, 12:56:01 AM
     */
    @Trace(operationName = "D-批量改排序")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public BatchUpdateSortNumRespDto batchUpdateSortNum(BatchUpdateSortNumReqDto reqDto) {


        //步骤0: M-批量修改排序（特殊方法） - batchUpdateSortNum
        //ModelCode: batchUpdateSortNumCom
        BatchUpdateSortNumRespDto batchUpdateSortNumComRes = null;
        BatchUpdateSortNumReqDto batchUpdateSortNumComReq = new BatchUpdateSortNumReqDto();
        if (reqDto != null) {
            batchUpdateSortNumComReq.setObjAttributeIdList(reqDto.getObjAttributeIdList().stream().map(item -> BeanUtil.toBean(item, ObjAttributeIdDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:55245_1
        }

        /*M-批量修改排序（特殊方法）[1809]  用于批量修改数据列表排序 */

        batchUpdateSortNumComRes = nbCommon.batchUpdateSortNum(batchUpdateSortNumComReq);


        BatchUpdateSortNumRespDto retData = new BatchUpdateSortNumRespDto();


        return retData;
    }

    /**
     * D上传附件[1836]
     */
    @Trace(operationName = "D上传附件")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    @BanAuto
    public AddUploadFileRespDto addUploadFile(AddUploadFileReqDto reqDto) {


//        String unknown_1 = null;
////步骤0: 上传附件 - addUploadFile
//        String unknown = null;
//        Object addUploadFileReq = new Object();
//        if (reqDto != null) {
//            addUploadFileReq = reqDto.getScope();
//            ;//sourceId:64224_1
//            addUploadFileReq = reqDto.getUse();
//            ;//sourceId:64175_1
//            addUploadFileReq = reqDto.getSpaceId();
//            ;//sourceId:64225_1
//            addUploadFileReq = reqDto.getFile();
//            ;//sourceId:64178_1
//        }
//
//        /*上传附件[1837]   */
//        unknown = mSpecMethordTableService.addUploadFile(addUploadFileReq);
//
//        unknown_1 = unknown;
//
        AddUploadFileRespDto retData = new AddUploadFileRespDto();
//        if (unknown_1 != null) {
//            retData.setUrl(unknown_1);//sourceId:56477_1
//        }


        return retData;
    }
    // @Resource
    // private MSpecMethordTableService mSpecMethordTableService;
    //
}
